package com.jason.android.widget.netimage;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;

public class NetImageView extends ImageView {
	private String mPicUrl = "";

	public NetImageView(Context context) {
		super(context);
	}

	public NetImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public NetImageView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public void setImageUrl(String url) {
		setImageUrl(url, false);
	}

	public void setImageUrl(String url, boolean isForce) {
		if (!isForce && mPicUrl.equals(url))
			return;
		mPicUrl = url;
		loadImage(url);
	}

	private void loadImage(String url) {
		new ImageDownloader(getContext()).download(mPicUrl, this);
	}

}
